module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    shell:{
        run:{
            command:'node server.js --inline'
        },
        kills:{
            command:'taskkill /F /FI "IMAGENAME eq node.exe" /FI "PID gt 10000" & node serverB'
        },
        linuxKill:{
            command:'kill `ps -a|grep node|grep server.js`'
        }
    },
      //less插件配置
      less: {
          main: {
              files:{
                  'public/css/main.css':'source/css/*.less'
              },
              options: {
                  livereload: true
              }
          }
      },
    watch: {
        client: {    //用于监听less文件,当改变时自动编译成css文件
            files: ['source/css/*.less'],
            tasks: ['less'],
            options: {
                livereload: true
            }
        },
        resetServer: {    //用于监听less文件,当改变时自动编译成css文件
            files: ['server/*/*'],
            tasks: ['shell:linuxKill','shell:run'],
            options: {
                livereload: true
            }
        },
      static: {
        files: ['pages/*','pages/*/*', 'public/*','public/*/*','public/*/*/*'],
        options: {
          livereload: true
        }
//      },
//      js: {
//        files: ['server/*.js','server/*/*.js'],
//        tasks:['shell:kills']
      }
    }
  });

  // 加载包含 "uglify" 任务的插件。
  grunt.loadNpmTasks('grunt-shell');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-contrib-less');

    // 默认被执行的任务列表。
    grunt.registerTask('default', ['watch']);
    grunt.registerTask('build', ['watch']);
};